home *** CD-ROM | disk | FTP | other *** search
- //------------------------------------------------------------------------------------------------------
- //------------------------------------------------------------------------------------------------------
- //------------------------------------------------------------------------------------------------------
-
- struct CSkinningOutput
- {
- float4 SkinnedPosition;
- float3 SkinnedNormal;
- float3 SkinnedBumpTangent;
- float3 SkinnedBumpNormal;
- };
-
- //------------------------------------------------------------------------------------------------------
-
- struct CSkinningOutput1Bone
- {
- float4 SkinnedPosition;
- float3 SkinnedNormal;
- };
-
- //------------------------------------------------------------------------------------------------------
-
- inline CSkinningOutput ComputeSkinning4Bones (const float3 inputPosition, const float3 inputNormal, const float3 inputBumpTangent, const float3 inputBumpNormal,
- const float4 bonesIndex, const float3 boneWeight,const matrix boneArray[18]);
-
- //------------------------------------------------------------------------------------------------------
-
- inline CSkinningOutput1Bone ComputeSkinning1Bone (const float3 inputPosition, const float3 inputNormal,
- const float4 bonesIndex, const float3 boneWeight,const matrix boneArray[18]);
-
- //------------------------------------------------------------------------------------------------------
- //------------------------------------------------------------------------------------------------------
- //------------------------------------------------------------------------------------------------------
-
- inline CSkinningOutput ComputeSkinning4Bones (const float3 inputPosition, const float3 inputNormal, const float3 inputBumpTangent, const float3 inputBumpNormal,
- const float4 bonesIndex, const float3 boneWeight,const matrix boneArray[18])
- {
- CSkinningOutput output;
-
- matrix accumulatedMatrix;
-
- float index0 = bonesIndex.z * 256.0f;
- float index1 = bonesIndex.y * 256.0f;
- float index2 = bonesIndex.x * 256.0f;
- float index3 = bonesIndex.w * 256.0f;
-
- float weight4 = 1.0f - (boneWeight.x + boneWeight.y + boneWeight.z);
-
- accumulatedMatrix = boneWeight.x * boneArray[index0];
- accumulatedMatrix += boneWeight.y * boneArray[index1];
- accumulatedMatrix += boneWeight.z * boneArray[index2];
- accumulatedMatrix += weight4 * boneArray[index3];
-
- float4 pos;
-
- pos.xyz = inputPosition;
- pos.w = 1.0f;
-
- output.SkinnedPosition = mul (pos,accumulatedMatrix);
-
- output.SkinnedBumpTangent = mul (inputBumpTangent,accumulatedMatrix);
- output.SkinnedBumpNormal = mul (inputBumpNormal,accumulatedMatrix);
- output.SkinnedNormal = mul (inputNormal,accumulatedMatrix);
-
-
- return output;
- }
-
- //------------------------------------------------------------------------------------------------------
- //------------------------------------------------------------------------------------------------------
- //------------------------------------------------------------------------------------------------------
-
- inline CSkinningOutput1Bone ComputeSkinning1Bone (const float3 inputPosition, const float3 inputNormal,
- const float4 bonesIndex, const float3 boneWeight,const matrix boneArray[18])
- {
- CSkinningOutput1Bone output;
-
- float index0 = bonesIndex.z * 256.0f;
-
- float4 pos;
-
- pos.xyz = inputPosition;
- pos.w = 1.0f;
-
- output.SkinnedPosition = mul (pos,boneArray[index0]);
- output.SkinnedNormal = mul (inputNormal,boneArray[index0]);
-
- return output;
- }
-
- //------------------------------------------------------------------------------------------------------
- //------------------------------------------------------------------------------------------------------
- //------------------------------------------------------------------------------------------------------